]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
WindowOverlay: fix title sizing
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 16 Dec 2012 23:42:40 +0000 (00:42 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 18 Dec 2012 15:00:54 +0000 (16:00 +0100)
After the first time the title was placed, we were setting its width,
thus forcing get_preferred_width() to return that as the minimum and
natural width.
To workaround that, explicitly reset the width to -1, -1, causing
StLabel->get_preferred_width() to be called, which would give us a meaningful
value for minimum and natural width.

https://bugzilla.gnome.org/show_bug.cgi?id=688234

js/ui/workspace.js

index acbcd377a7c6171e502550d2faf20b4466083087..25877b20b1b040f9665eb58c4838e27804df5682 100644 (file)
@@ -557,8 +557,16 @@ const WindowOverlay = new Lang.Class({
         else
             button.set_position(Math.floor(buttonX), Math.floor(buttonY));
 
+        // Clutter.Actor.get_preferred_width() will return the fixed width if one
+        // is set, so we need to reset the width by calling set_width(-1), to forward
+        // the call down to StLabel.
+        // We also need to save and restore the current width, otherwise the animation
+        // starts from the wrong point.
+        let prevTitleWidth = title.width;
+        title.set_width(-1);
         let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1);
         let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth));
+        title.width = prevTitleWidth;
 
         let titleX = cloneX + (cloneWidth - titleWidth) / 2;
         let titleY = cloneY + cloneHeight + title._spacing;